import XLSX from 'xlsx';

let arrayData = [
  ['name', 'age'],
  ['zhangsan', 20],
  ['lisi', 21],
  ['wangwu', 22],
  ['zhaoliu', 23],
  ['sunqi', 24],
];

let jsonData = [{
  name: "zhangsan1",
  age: 30
}, {
  name: "lisi1",
  age: 31
}, {
  name: "wangwu1",
  age: 32
}, {
  name: "zhaoliu1",
  age: 33
}, {
  name: "sunqi1",
  age: 34,
  length: "hello"
}];

// 将数据转成workSheet
let jsonWorkSheet = XLSX.utils.json_to_sheet(jsonData);
// console.log(arrayWorkSheet);
// console.log(jsonWorkSheet);
// 构造workBook
let workBook = {
  SheetNames: ['jsonWorkSheet'],
  Sheets: {
    'jsonWorkSheet': jsonWorkSheet,
  }
};
// 将workBook写入文件
XLSX.writeFile(workBook, "./aa.xlsx");
